using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using FoundationLib.Ifc.Data;
using FoundationLib.Ifc.Domain;


namespace FoundationLib.Ifc.Data 
{
	/// <summary>
	/// Provides an interface for event storage types supporting aggregate
	/// snapshotting
	/// </summary>
	public interface ISnapshotAggregateEventStorage : IAggregateEventStorage 
	{
		/// <summary>
		/// Retrieves all events which occurred
		/// after the latest snapshot
		/// </summary>
		/// <returns>All events which occurred after the time of the latest
		/// snapshot</returns>
		/// <param name="aggregateKey">The aggregate key</param>
		IEnumerable<IVersionedEvent> GetAllSinceLatestSnapshot(object aggregateKey);

		/// <summary>
		/// Retrieves the latest snapshot for the aggregate with the given key
		/// </summary>
		/// <param name="aggregateKey">The aggregate key</param>
		/// <returns>The latest snapshot</returns>
		object GetLatestSnapshot(object aggregateKey);

		/// <summary>
		/// Saves a snapshot for the aggregate with the given key
		/// </summary>
		/// <param name="aggregateKey">The aggregate key</param>
		/// <param name="version">The version of the aggregate at the time the snapshot was
		/// taken</param>
		/// <param name="snapshot">The serialized aggregate snapshot data</param>
		void SaveSnapshot(object aggregateKey, int version, object snapshot);
	}

}